<%@page import="java.net.URLDecoder" %>
<%
	String type = request.getParameter("type").toString();
 	int current = Integer.parseInt(request.getParameter("currentPage").toString());
	long totalResult = Long.parseLong(request.getParameter("totalResult").toString());
	int totalPage = (int)totalResult/12;
	totalPage = totalPage + 1;	
	if(totalPage>30){
		totalPage = 30;
	}
	String searchKey = request.getParameter("searchKey").toString();
	searchKey = URLDecoder.decode(searchKey, "UTF8").replaceAll(" ", "+");
	
%> 
<ul class="paginatia paginatiaD paginatiaD06">
		<%
			if(current!=1){
				%>
				<li><a class="first" href="/<%=type %>/<%= searchKey%>/<%=1%>">First Page</a></li>
				<%
			}
		%>
					
		<%
			if(current>1){
		%>
					<li><a class="first" href="/<%=type%>/<%= searchKey%>/<%=(current-1)%>">Previous</a></li>
		<%
			}
			int totalButton = 7;
			int pre=0;
		%>
		<%	
				for(int i = (current -3); i< current;i++){
					if(i>0){
						pre++;
		%>
						<li><a href="/<%=type %>/<%= searchKey%>/<%=i%>"><%=i%></a></li>
		<%		
					}
				}			
		%>	
		<li><a class="current" href="/<%=type %>/<%= searchKey%>/<%=current%>"><%=current %></a></li>		
		<%
			for(int i = (current + 1); i < (current + (totalButton-pre)); i++){
				if(i>30||i>totalPage){
					break;
				}
				%>
					<li><a href="/<%=type %>/<%= searchKey%>/<%=i%>"><%=i%></a></li>
				<%
			}
		%>		
		<%
			if(current!=totalPage){
		%>
			<li><a href="/<%=type %>/<%= searchKey%>/<%=(current+1)%>">Next</a></li>
		<%
			}
		%>		
		
</ul>